package cz.zcu.fav.ratdroid.adapter;

import java.util.List;

import cz.zcu.fav.ratdroid.R;
import cz.zcu.fav.ratdroid.bean.Object;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ObjectsArrayAdapter extends ArrayAdapter<Object>
{

	private final Context context;

	public ObjectsArrayAdapter(Context context, int textViewResourceId,
			List<Object> objects)
	{
		super(context, textViewResourceId, objects);
		this.context = context;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{
		View v = convertView;
		if (v == null)
		{

			LayoutInflater vi = (LayoutInflater) context
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(R.layout.object_row, null);
		}

		Object obj = getItem(position);
		if (obj != null)
		{
			((TextView) v).setText(obj.getName());
		}

		return v;
	}
}
